package br.com.salao.session;

import java.util.Date;
import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import br.com.salao.ejb.dao.DateBusyDao;
import br.com.salao.ejb.dao.impl.DateBusyDaoImpl;
import br.com.salao.entity.DateBusy;

@Stateless
@Remote(DateBusyBase.class)
public class DateBusyBean implements DateBusyBase {

	/**
	 * @author Dri
	 */
	private static final long serialVersionUID = 1L;

	@PersistenceContext(unitName = "SalaoBeleza")
	private EntityManager em;

	public DateBusyBean(){
		//	em = JpaUtil.getEntityManager();	
	}

	@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
	public List<DateBusy> buscarDatasFechadasPorEstab(int idEstabelecimento){	
		DateBusyDao busyDao = new DateBusyDaoImpl(em);
		return busyDao.buscarDateBusyPorEstabelecimento(idEstabelecimento);
	}

	@TransactionAttribute
	public DateBusy inserir(DateBusy dateBusy){
		DateBusyDao busyDao = new DateBusyDaoImpl(em);
		return busyDao.inserir(dateBusy);
	}

	@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
	public List<DateBusy> buscarDateBusyPorEstabelecimentoEData(int idEstabelecimento, Date dataFechada){
		DateBusyDaoImpl dao = new DateBusyDaoImpl(em);
		return dao.buscarDateBusyPorEstabelecimentoEData(idEstabelecimento, dataFechada);
	}

	@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
	public List<DateBusy> buscarDateBusyPorEstabelecimento(int idEstabelecimento) {
		DateBusyDaoImpl dao = new DateBusyDaoImpl(em);
		return dao.buscarDateBusyPorEstabelecimento(idEstabelecimento);
	}

}
